package com.by.toolkit.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Tian Wei
 * @version 1.0
 * @date 2023/12/26 5:16 PM
 */


@Slf4j
@Getter
@AllArgsConstructor
public enum ErrorCodeEnum {

    SUCCESS("OK", "成功"),

    BIZ_FAIL("BIZ_FAIL", "业务逻辑异常"),

    PARAM_CHK_ERROR("PARAM_CHK_ERROR", "参数异常"),

    SYS_ERROR("SYS_ERROR", "系统内部异常"),

    EXPIRE_TYPE("TOKEN_EXPIRE", "token已失效，请重新登录"),

    ILLEGAL_TYPE("TOKEN_ILLEGAL", "token非法"),

    SIGNATURE_ERROR_TYPE("TOKEN_SIGNATURE_ERROR", "token签名异常"),

    TOKEN_NOT_EXIST("TOKEN_NOT_EXIST", "token信息不存在"),

    USER_ID_DISABLED("USER_ID_DISABLED", "用户已经被禁用"),

    PATH_NOT_AUTHORIZATION("PATH_NOT_AUTHORIZATION", "路径未授权"),

    REQUEST_HEADER_SET_FAIL("REQUEST_HEADER_SET_FAIL", "请求头设置失败"),

    GATE_ERROR("GATE_ERROR", "网关请求数据异常"),

    CLIENT_REQUEST_NOT_EXIST("CLIENT_REQUEST_NOT_EXIST", "无客户端类型请求类型"),

    REQUEST_HEADER_MISS("REQUEST_HEADER_MISS", "请求头数据丢失"),

    ILLEGAL_SERVICE_EXCEPTION("ILLEGAL_SERVICE_EXCEPTION", "非业务型异常,请核查"),

    HTTP_METHOD_UNSUPPORT("HTTP_METHOD_UNSUPPORT", "请求方式不正确"),

    ADMIN_ACCOUNT_INFO_NOT_EXIST("ADMIN_ACCOUNT_INFO_NOT_EXIST", "账号信息不存在"),

    ADMIN_PASSWORD_ERROR("ADMIN_PASSWORD_ERROR", "登陆密码错误"),

    ADMIN_LOGIN_TYPE_ERROR("ADMIN_LOGIN_TYPE_ERROR", "登陆类型错误"),

    NO_SEARCH_PARTNER_AUTHOR_CONFIG("NO_SEARCH_PARTNER_AUTHOR_CONFIG","未查询到第三方授权配置信息"),

    WECHAT_ILLEGALITY_OAUTH_CODE("WECHAT_ILLEGALITY_OAUTH_CODE","不合法的 oauth_code"),

    WECHAT_OAUTH_CODE_USED("WECHAT_OAUTH_CODE_USED","oauth_code已使用"),

    WECHAT_OAUTH_FAILED("WECHAT_OAUTH_FAILED","微信授权失败"),

    REDIS_LOCK_FAILED("LOCK_FAILED","其他人员在操作，请稍后再试"),

    DATE_EMPTY("DATE_EMPTY", "参数缺失"),

    BIZ_ORDER_WX_SYSTEM_CHK("BIZ_ORDER_WX_SYSTEM_CHK", "微信支付系统校验"),

    BIZ_OVER_RATE_LIMIT("BIZ_OVER_RATE_LIMIT", "操作过于频繁，请稍后再试"),

    BIZ_ALI_NOTIFY_CHK("BIZ_ALI_NOTIFY_CHK", "支付宝回调的状态是TRADE_FINISHED（交易结束），不处理"),

    WX_AUTHOR_CODE_ALREADY_USED("WX_AUTHOR_CODE_ALREADY_USED", "微信授权码已经被使用,请重新获取"),

    PHONE_ALREADY_BIND_OTHER_ACCOUNT("PHONE_ALREADY_BIND_OTHER_ACCOUNT","手机号已经绑定其他账号"),

    ALREADY_BIND_OTHER_PHONE("ALREADY_BIND_OTHER_PHONE","当前用户已经绑定其他手机号"),

    THIRD_LIVE_SIGN("THIRD_LIVE_SIGN","三方直播签名验证失败"),

    UN_SIGN_CONTRACT("UN_SIGN_CONTRACT","用户未签署合同"),

    WX_REFUND("WX_REFUND","微信退款失败"),

    ALI_REFUND("ALI_REFUND","支付宝退款失败"),

    NEED_WX_OAUTH("NEED_WX_OAUTH","需要微信授权"),

    SYS_USER_ALREADY_EXIST("SYS_USER_ALREADY_EXIST","用户已存在"),

    DB_UK_IDX("DB_UK_IDX","数据已存在"),

    COURSE_WARE_UNLOCK("COURSE_WARE_UNLOCK","课件未解锁"),

    COURSE_WARE_PERMISSION_DENIED("COURSE_WARE_PERMISSION_DENIED","课件无权限查看"),

    COURSE_WARE_PERMISSION_NEED_ADJUST("COURSE_WARE_PERMISSION_NEED_ADJUST","需要调班后可看"),

    CLASS_DIVIDE_NEED_ID("CLASS_DIVIDE_NEED_ID","班级分班需要班级id"),

    COURSE_CURRICULUM_WARE_VIEW_AUDIT("COURSE_CURRICULUM_WARE_VIEW_AUDIT","课程-课表课件申请通过后可观看"),

    NO_VIEW_CURRICULUM_WARE_PERMISSION("NO_VIEW_CURRICULUM_WARE_PERMISSION","暂无观看权限"),

    WX_CP_AUTHOR_CODE_ILLEGAL("WX_CP_AUTHOR_CODE_ILLEGAL","不合法的oauth_code"),

    WX_CP_SIDEBAR_AUTO_LOGIN_FAIL("WX_CP_SIDEBAR_AUTO_LOGIN_FAIL","企业侧边栏自动登陆失败"),

    ES_NO_ROUTE_SOURCE_CONFIG("ES_NO_ROUTE_SOURCE_CONFIG","es未配置数据源"),

    PROJECT_DEBT("PROJECT_DEBT","项目已欠费，请联系管理员！"),

    WX_CP_API_NOT_EXIST("WX_CP_API_NOT_EXIST","企业微信接口不存在"),

    GET_LOCK_FAIL("GET_LOCK_FAIL","获取锁失败"),

    WX_CP_CHAT_FILE_PROCESS_REASON("WX_CP_CHAT_FILE_PROCESS_REASON","会话存档文件处理失败"),

    ;

    private final String errorCode;

    private final String errorMessage;

    private static final Map<String, String> ERROR_CODE_ENUM_MAP;

    static {

        ERROR_CODE_ENUM_MAP = Stream.of(ErrorCodeEnum.values()).collect(Collectors.toUnmodifiableMap(ErrorCodeEnum::getErrorCode, ErrorCodeEnum::getErrorCode));

    }

}
